package com.tidc.authentication;


import com.tidc.authentication.properties.AuthConfigProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;

import javax.sql.DataSource;

@SpringBootApplication
@EnableFeignClients
@MapperScan("com.tidc/authentication.mapper")
@EnableConfigurationProperties(AuthConfigProperties.class)//这是让SecurityProperties这个类生效
public class AuthenticationApplication {

	public static void main(String[] args) {
		SpringApplication.run(AuthenticationApplication.class, args);
	}
	@Primary
	@Bean
	public ClientDetailsService clientDetails(DataSource dataSource) {
		return new JdbcClientDetailsService(dataSource);
	}
	@Bean
	public PasswordEncoder PasswordEncoder(){
		return new BCryptPasswordEncoder();
	}
}
